package org.jeecg.modules.cosmetic.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.cosmetic.handler.ToxicologicalEdibleHandler;
import org.jeecg.modules.cosmetic.model.vo.DeleteVO;
import org.jeecg.modules.cosmetic.model.vo.ToxEdibleVO;
import org.jeecg.modules.cosmetic.utils.MyValidateUtil;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 毒理数据库食用性表 前端控制器
 * </p>
 *
 * @author lq
 * @since 2024-02-29 13:57:48
 */
@Api(tags = "可食用性")
@RestController
@RequestMapping("/api/tox/edible")
public class TToxicologicalEdibleController {

    @Resource
    private ToxicologicalEdibleHandler toxicologicalEdibleHandler;

    @ApiOperation(value = "保存-更新数据", notes = "保存-更新数据")
    @PostMapping(value = "/save_update")
    public Result<?> saveOrupdate(@RequestBody ToxEdibleVO vo) {
        MyValidateUtil.validThrow(vo);
        return toxicologicalEdibleHandler.saveOrUpdate(vo);
    }

    @ApiOperation(value = "查询数据", notes = "查询数据")
    @GetMapping(value = "/get")
    public Result<?> getEdible(@RequestParam("id") Long id) {
        return Result.ok(toxicologicalEdibleHandler.getEdible(id));
    }

    @ApiOperation(value = "查询可食用数据详情", notes = "查询可食用数据详情")
    @GetMapping(value = "/detail")
    public Result<?> getEdibleDetail(@RequestParam("id") Long id) {
        return Result.ok(toxicologicalEdibleHandler.getEdible(id));
    }

    @ApiOperation(value = "删除可食用性数据", notes = "删除可食用性数据")
    @DeleteMapping(value = "/delete")
    public Result<?> delete(@RequestBody DeleteVO vo) {
        return Result.ok(toxicologicalEdibleHandler.delete(vo.getId()));
    }
}
